<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>将 PKCS7 文件导出为 PEM 格式证书的数组</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.openssl-pkcs7-encrypt.html">« openssl_pkcs7_encrypt</a></li>
      <li style="float: right;"><a href="function.openssl-pkcs7-sign.html">openssl_pkcs7_sign »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.openssl.html">OpenSSL 函数</a></li>
    <li>将 PKCS7 文件导出为 PEM 格式证书的数组</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.openssl-pkcs7-read" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">openssl_pkcs7_read</h1>
  <p class="verinfo">(PHP 7 &gt;= 7.2.0, PHP 8)</p><p class="refpurpose"><span class="refname">openssl_pkcs7_read</span> &mdash; <span class="dc-title">将 PKCS7 文件导出为 PEM 格式证书的数组</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.openssl-pkcs7-read-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>openssl_pkcs7_read</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$input_filename</code></span>, <span class="methodparam"><span class="type">array</span> <code class="parameter reference">&$certificates</code></span>): <span class="type">bool</span></div>

  <p class="para rdfs-comment">

  </p>

  <div class="warning"><strong class="warning">警告</strong><p class="simpara">本函数还未编写文档，仅有参数列表。</p></div>

 </div>


 <div class="refsect1 parameters" id="refsect1-function.openssl-pkcs7-read-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">input_filename</code></dt>

    <dd>

     <p class="para">
      想要解析的字符串数据（p7b 格式）。
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">certificates</code></dt>

    <dd>

     <p class="para">
      PEM 格式证书的数组，来源于输入的 p7b 数据。
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.openssl-pkcs7-read-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>true</code></strong>， 或者在失败时返回 <strong><code>false</code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.openssl-pkcs7-read-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-947">
    <p><strong>示例 #1 根据 P7B 文件获取 PEM 数组</strong></p>
    <div class="example-contents">
     <div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$file&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'certs.p7b'</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$f&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">file_get_contents</span><span style="color: #007700">(</span><span style="color: #0000BB">$file</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$p7&nbsp;</span><span style="color: #007700">=&nbsp;array();<br /></span><span style="color: #0000BB">$r&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">openssl_pkcs7_read</span><span style="color: #007700">(</span><span style="color: #0000BB">$f</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$p7</span><span style="color: #007700">);<br /><br />if&nbsp;(</span><span style="color: #0000BB">$r&nbsp;</span><span style="color: #007700">===&nbsp;</span><span style="color: #0000BB">false</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"ERROR:&nbsp;%s&nbsp;is&nbsp;not&nbsp;a&nbsp;proper&nbsp;p7b&nbsp;file"</span><span style="color: #007700">.</span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$file</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(</span><span style="color: #0000BB">$e&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">openssl_error_string</span><span style="color: #007700">(),&nbsp;</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$e</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$e&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">openssl_error_string</span><span style="color: #007700">(),&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">++)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"SSL&nbsp;l%d:&nbsp;%s"</span><span style="color: #007700">.</span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$e</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;exit(</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$p7</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>

  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.openssl-pkcs7-read-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.openssl-csr-sign.html" class="function" rel="rdfs-seeAlso">openssl_csr_sign()</a> - 用另一个证书签署 CSR (或者本身) 并且生成一个证书</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>